package com.cuit.controller;

import com.cuit.pojo.Users;
import com.cuit.service.MenuListService;
import com.cuit.utils.Result;
import com.cuit.utils.UserThreadLocal;
import com.cuit.vo.MenuListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class MenuController {

    @Autowired
    private MenuListService menuListService;

    @GetMapping("/menu" )
    private Result getMenuList(){
        Users users = UserThreadLocal.get();
        Integer roleId = users.getRoleId();
        List<MenuListVo> menuListUser = menuListService.getMenuListUser(roleId);
        return Result.success(menuListUser);
    }
}
